﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace CControl
{
    public class Cls_DetalleEvento
    {

        public int id_activos { get; set; }
        public string nombre { get; set; }
        public string descripcion { get; set; }
        public string tipo { get; set; }
        public int id_marca { get; set; }
        public decimal precio { get; set; }
        public int id_logistica { get; set; }
        public int cantidad { get; set; }
        public int id_evento { get; set; }

        public bool mtd_AgregarDetalleEvento()
        {
            try
            {

                //oConexion.ConnectionString = _ConnectionString;
                //oConexion.Open();
                Cls_Conexion Objconexion = new Cls_Conexion();
                SqlCommand Objcomando = new SqlCommand();
                SqlDataAdapter ObjDataAdapter = new SqlDataAdapter();
                DataTable ObjDataTable = new DataTable();
             
                Objcomando.CommandType = CommandType.StoredProcedure;
                Objcomando.CommandText = "USP_I_INSERTAR_LOGISTICA";                         

                Objcomando.Parameters.Add(new SqlParameter("@LOGcantidad", SqlDbType.VarChar));
                Objcomando.Parameters.Add(new SqlParameter("@ACTid_activos", SqlDbType.VarChar));
                Objcomando.Parameters.Add(new SqlParameter("@EVTid_evento", SqlDbType.Char));
                

                Objcomando.Parameters["@LOGcantidad"].Value = this.cantidad;
                Objcomando.Parameters["@ACTid_activos"].Value = this.id_activos;
                Objcomando.Parameters["@EVTid_evento"].Value = this.id_evento;
                
                Objcomando.Connection = Objconexion.Conectar();
                Objcomando.ExecuteNonQuery();

                return true;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Cls_Conexion desconectar = new Cls_Conexion();
                desconectar.Desconectar();
            }
        }

        public static DataTable mtd_Listar_Activos_Bebidas()
        {            
            try
            {
                Cls_Conexion Objconexion = new Cls_Conexion();
                SqlCommand Objcomando = new SqlCommand();
                SqlDataAdapter ObjDataAdapter = new SqlDataAdapter();
                DataTable ObjDataTable = new DataTable();

                Objcomando.CommandText = "USP_S_LISTAR_ACTIVOS_BEBIDAS";

                Objcomando.Connection = Objconexion.Conectar();
                Objcomando.ExecuteNonQuery();

                ObjDataAdapter.SelectCommand = Objcomando;
                ObjDataAdapter.Fill(ObjDataTable);

                Objconexion = null;
                ObjDataAdapter = null;

                return ObjDataTable;
            }
            catch (Exception ex)
            {
                throw ex;
                //throw new Exception("System Error.");
            }
            finally
            {
                Cls_Conexion Objconexion = new Cls_Conexion();
                Objconexion.Desconectar();
            }
        }
    }
}
